package com.qianclass.talklive.app.json.ImSendMessge;

import com.qianclass.talklive.app.bean.CountTimeBean;
import com.qianclass.talklive.app.utils.Constant;
import com.qianclass.talklive.app.utils.LogUtil;
import com.qianclass.talklive.app.utils.ThreadUtils;
import com.google.gson.Gson;

import static com.qianclass.talklive.app.activity.VideoActivity.egine;


/**
 * 开始计时
 * {"message":{"type":"timer","subcommand":"start"}}
 */

public class SendClockMessage {

    /**
     * @param group
     * @param secondCount
     */
    public static void sendMessge(final String group, int secondCount) {
        try {
            CountTimeBean countTimeBean  = new CountTimeBean();
            CountTimeBean.MessageBean messageBean = new CountTimeBean.MessageBean();

            messageBean.setType("timer");
            messageBean.setSubcommand("start");
            messageBean.setSecondcounts(secondCount);

            countTimeBean.setMessage(messageBean);

            Gson gson = new Gson();
            final String jsonString = gson.toJson(countTimeBean);
            ThreadUtils.runOnSubThread(new Runnable() {
                @Override
                public void run() {
                    egine.SendGroupMessage(Constant.CONTROLMSGTYPE, group, jsonString);
                }
            });
            LogUtil.i("计时" ,jsonString);
        } catch (Exception e){
            LogUtil.i("计时" , "发送信息失败");
        }

    }
}
